/*    */ package com.jcrj.util;
/*    */ 
/*    */ import java.io.PrintStream;
/*    */ import java.util.Date;
/*    */ import java.util.regex.Matcher;
/*    */ import java.util.regex.Pattern;
/*    */ 
/*    */ public class GetText
/*    */ {
/*    */   public static String Html2Text(String inputString)
/*    */   {
/*  9 */     String htmlStr = inputString;
/* 10 */     String textStr = "";
/*    */     try
/*    */     {
/* 25 */       String regEx_script = "<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>";
/* 26 */       String regEx_style = "<[\\s]*?style[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?style[\\s]*?>";
/* 27 */       String regEx_html = "<[^>]+>";
/* 28 */       String regEx_blank = " +";
/* 29 */       String regEx_table = "\t+";
/* 30 */       String regEx_spe = "\\&[^;]+;";
/* 31 */       Pattern p_script = Pattern.compile(regEx_script, 2);
/* 32 */       Matcher m_script = p_script.matcher(htmlStr);
/* 33 */       htmlStr = m_script.replaceAll("");
/*    */ 
/* 35 */       Pattern p_style = Pattern.compile(regEx_style, 2);
/* 36 */       Matcher m_style = p_style.matcher(htmlStr);
/* 37 */       htmlStr = m_style.replaceAll("");
/*    */ 
/* 39 */       Pattern p_html = Pattern.compile(regEx_html, 2);
/* 40 */       Matcher m_html = p_html.matcher(htmlStr);
/* 41 */       htmlStr = m_html.replaceAll("");
/*    */ 
/* 43 */       Pattern p_blank = Pattern.compile(regEx_blank, 2);
/* 44 */       Matcher m_blank = p_blank.matcher(htmlStr);
/* 45 */       htmlStr = m_blank.replaceAll(" ");
/*    */ 
/* 47 */       Pattern p_table = Pattern.compile(regEx_table, 2);
/* 48 */       Matcher m_table = p_table.matcher(htmlStr);
/* 49 */       htmlStr = m_table.replaceAll(" ");
/*    */ 
/* 51 */       Pattern p_spe = Pattern.compile(regEx_spe, 2);
/* 52 */       Matcher m_spe = p_spe.matcher(htmlStr);
/* 53 */       htmlStr = m_spe.replaceAll("");
/*    */ 
/* 55 */       textStr = htmlStr;
/*    */     } catch (Exception e) {
/* 57 */       System.err.println("Html2Text: " + e.getMessage());
/*    */     }
/* 59 */     return textStr;
/*    */   }
/*    */ 
/*    */   public static String getFwHtmlText(String content, String name)
/*    */   {
/* 64 */     String html = "";
/* 65 */     if ((content != null) && (!"".equals(content))) {
/* 66 */       html = html + "<table border='0' width='650px'>";
/* 67 */       html = html + "<tr><td width='450px'>&nbsp;&nbsp;<font color='black'>" + content + "</font></td><td width='200px'>&nbsp;</td></tr>";
/* 68 */       html = html + "<tr><td>&nbsp;</td><td align='right'><font color='black'>" + name + "&nbsp;(" + DateUtil.DateToFormat(new Date()) + ")</font></td></tr></table>";
/*    */     } else {
/* 70 */       html = html + "<table border='0' width='650px'>";
/* 71 */       html = html + "<tr><td width='450px'>&nbsp;&nbsp;</td><td width='200px' >&nbsp;</td></tr>";
/* 72 */       html = html + "<tr><td>&nbsp;</td><td align='right'><font color='black'>" + name + "&nbsp;(" + DateUtil.DateToFormat(new Date()) + ")</font></td></tr></table>";
/*    */     }
/* 74 */     return html;
/*    */   }
/*    */ 
/*    */   public static String isEmpty(Object obj)
/*    */   {
/* 79 */     if (obj != null) {
/* 80 */       return obj.toString();
/*    */     }
/* 82 */     return "";
/*    */   }
/*    */ }